package com.seecen.cywbackend.controller;

import com.seecen.cywbackend.pojo.vo.DynamicQuery;
import com.seecen.cywbackend.service.DynamicService;
import com.seecen.cywbackend.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dynamic")
public class DynamicController {
    @Autowired
    private DynamicService dynamicService;

    @GetMapping("/list")
    public Result getDynamicList(
            @RequestParam(required = false) Integer tabType,
            @RequestParam(required = false) Integer groupId,
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "5") Integer size,
            @RequestHeader String uid) {

        DynamicQuery query = new DynamicQuery();
        query.setTabType(tabType);
        query.setGroupId(groupId);
        query.setCurrent(current);
        query.setSize(size);
        query.setCurrentUserId(Long.valueOf(uid));

        return Result.ok(dynamicService.pageDynamicList(query));
    }

}
